// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model User {
  id       String    @id @default(uuid())
  name     String
  email    String    @unique
  password String
  products Product[]
  order    Order[]
}

model Product {
  id          String @id @default(uuid())
  title       String
  price       String
  description String
  image       String

  user   User   @relation(fields: [userId], references: [id])
  userId String

  categories Category @relation(fields: [categoryId], references: [slug])
  categoryId String

  order Order[]
}

model Category {
  id   String @id @default(uuid())
  name String

  slug     String    @unique
  products Product[]
}

model Order {
  id String @id @default(uuid())

  createdAt DateTime @default(now())

  userId String
  user   User   @relation(fields: [userId], references: [id])

  productId String
  product   Product @relation(fields: [productId], references: [id])

  quantity Int
  total    Float
}
